package com.mida.bms.report.api;


import com.mida.bms.report.vo.ImageVo;
import com.mida.tool.common.result.ActionResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.DependsOn;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.awt.*;
import java.util.List;

@DependsOn("loadFromDatabasePropertyConfig")
@FeignClient(name = "imageApi", url = "bms.report.feign.url")
public interface ImageApi {



    /**
     * 图片上传
     * @param file
     * @param postId
     * @return
     */
    @PostMapping(value = "/imageController/uploadImg",produces = {"application/json"},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String uploadImg(@RequestPart("file") MultipartFile file,
                            @RequestParam("postId") String postId,
                            @RequestParam("personSoid")String personSoid,
                            @RequestParam("customerSoid")String customerSoid,
                            @RequestParam("registrationSoid")String registrationSoid,
                            @RequestParam("loginUserId")Long loginUserId);


    /**
     * 获取图片列表
     * @param postId
     * @return
     */
    @GetMapping(value = "/imageController/queryImageList")
    List<ImageVo> queryImageList(@RequestParam("postId") String postId);


    /**
     * 删除图片
     * @param postId
     * @param imageName
     * @return
     */
    @PostMapping(value = "/imageController/deleteImage",produces = {"application/json"})
    @ResponseBody
    ActionResult deleteImage(@RequestParam("postId") String postId, @RequestParam("imageName") String imageName);





    /**
     * 压缩文件上传
     * @param file
     * @param postId
     * @return
     */
    @PostMapping(value = "/imageController/decompression",produces = {"application/json"},consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ResponseBody
    public String decompression(@RequestPart("file") MultipartFile[] file,
                            @RequestParam("postId") String postId,
                            @RequestParam("personSoid")String personSoid,
                            @RequestParam("customerSoid")String customerSoid,
                            @RequestParam("registrationSoid")String registrationSoid,
                            @RequestParam("loginUserId")Long loginUserId);




    /**
     * 图片上传后维护数据库
     * @return
     */
    @PostMapping(value = "/imageController/maintainData")
    @ResponseBody
    ActionResult maintainData(@RequestParam("postId")String postId, @RequestParam("personSoid")String personSoid,
                              @RequestParam("customerSoid")String customerSoid,
                              @RequestParam("registrationSoid")String registrationSoid,
                              @RequestParam("imagePath")String imagePath);


}
